/* $Id: SubmissionDetailsEntry.java 137 2011-08-29 20:33:36Z altdotua@gmail.com $ */

package alt.djudge.frontend.server.datatypes;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import alt.djudge.frontend.shared.dto.admin.AdminDTOEntry;
import alt.djudge.frontend.shared.dto.admin.SubmissionDetailsEntryDTO;


@PersistenceCapable(detachable="true")
public class SubmissionDetailsEntry extends AbstractEntry
{
	private static final long serialVersionUID = 1L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	protected Long id;
	
	@Override
	public Long getId()
	{
		return id;
	}
	
	@Override
	public void setId(Long id)
	{
		this.id = id;
	}
	
	@Persistent
	private byte[] sourceCode;
	
	@Persistent
	private byte[] xmlReport;

	public String getSourceCode()
	{
		return new String(sourceCode);
	}

	public void setSourceCode(String sourceCode)
	{
		this.sourceCode = sourceCode.getBytes();
	}

	public String getXmlReport()
	{
		return new String(xmlReport);
	}

	public void setXmlReport(String xmlReport)
	{
		this.xmlReport = xmlReport.getBytes();
	}

	@Override
	public AdminDTOEntry ownAdminDTO()
	{
		String[] data = new String[] {
			getId().toString(),
			getSourceCode(),
			getXmlReport()
		};
		return new SubmissionDetailsEntryDTO(data);
	}
}
